package com.example.fw;

import java.io.IOException;
import java.util.Properties;


public class ApplicationManager {
	private static ApplicationManager instance;
	
	public static ApplicationManager getInstance(Properties props) throws IOException{
		if(instance == null){
			instance = new ApplicationManager();
			instance.setProperties(props);
			instance.start(); 
		}
		return instance;
	}
	
	
	private Properties properties;
	private ContactHelper contactHelper;
	private ProcessHelper processHelper;
	private AutoItHelper autoItHelper;

	public void start() throws IOException{
		getProcessHelper().startAppUnderTest();
	}
	
	public void stop() {
		getProcessHelper().stopAppUnderTest();
	}
	
	public String getProperty(String key){
		return properties.getProperty(key);
	}
	
	public Properties getProperties() {
		return properties;
	}
	
	public void setProperties(Properties properties){
		this.properties = properties;
	}

	public ContactHelper getContactHelper() {
		if(contactHelper == null){
			contactHelper = new ContactHelper(this);
		}
		
		return contactHelper;
	}
	
	public ProcessHelper getProcessHelper() {
		if(processHelper == null){
			processHelper  = new ProcessHelper(this);
		}
		
		return processHelper ;
	}
	
	public AutoItHelper getAutoItHelper() {
		if(autoItHelper == null){
			autoItHelper  = new AutoItHelper(this);
		}
		
		return autoItHelper ;
	}
}
